package com.struts.service.impl;

import java.io.IOException;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import javax.servlet.http.HttpServletResponse;

import org.springframework.util.StringUtils;

import com.struts.pojo.User;
import com.struts.service.IUserService;

public class UserServiceImpl implements IUserService{

	@Override
	public Map<String, User> getUser(Map<String, Object> map) {
		String path;
		User u = new User();
		if(null == map.get("sex")){
			
			u.setAddr("����");
			u.setSex("��");
			u.setAge("20");
			u.setName("��С��");
			path="boy";
		}else{
			
			u.setAddr("�Ϻ�");
			u.setSex("Ů");
			u.setAge("20");
			u.setName("С��");
			path="girl";
		}
		Map<String, User> mapc = new HashMap<String, User>();
		mapc.put(path, u);
		return mapc;
	}

	@Override
	public User getUserById(Map<String, Object> map) {
		User u = new User();
		
			
			u.setAddr("重庆");
			u.setSex("女");
			u.setAge("20");
			u.setName("店小二");
			
		return u ;
	}

	@Override
	public User getUserByName(Map<String, Object> map) {
		// TODO Auto-generated method stub
		return null;
	}

	@Override
	public User getUserByAge(Map<String, Object> map) {
		// TODO Auto-generated method stub
		return null;
	}

	@Override
	public String getUserList(Map<String, Object> map) {
		String path;
		List<User> list = new ArrayList<User>();
		for (int i = 0; i < 10; i++) {
			User u = new User();
			u.setName("店小"+i);
			u.setAddr("重庆"+i+"路");
			u.getAge("2"+i);
			if(i%2==0){
				u.setSex("男");
			}else{
				u.setSex("女");
			}
			list.add(u);
		}
		if(map.get("sex").equals("1")){ 
			path="boy";
		}else{
			path="girl";
		}
		 /*try {
			    PrintWriter writer = response.getWriter();
			    writer.write(list.toString());
			    
		} catch (IOException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}finally{
		}*/
		
		return path;
	}

}
